package dao;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public abstract class AbstractDAOUtil {
	private static SqlSessionFactory sqlessionFactory = null;
	
	private AbstractDAOUtil(){}
	
	public static SqlSessionFactory GetSqlSessionFactory(){

		if(sqlessionFactory == null){
			Reader reader = null;
			
			try {
				reader = Resources.getResourceAsReader("mybatis.xml");
			} catch (IOException e) {
				e.printStackTrace();
				return null;
			}
			sqlessionFactory = new SqlSessionFactoryBuilder().build(reader);
		}
		return sqlessionFactory;
	}
	
}
